;*****************************************************************************************************
;+
; NAME:
;
;      IGL_GetCurrentWindow
;
; PURPOSE:
;
;      This routine is used to conveniently get the object reference of the current
;      IGL window. It should never be called directly by the user.
;
; CALLING SEQUENCE:
;
;      window = IGL_GetCurrentWindow()
;
; ARGUMENTS:
;
;      None.
;                 
; KEYWORD PARAMETERS:
;
;      CURRENTID:     Set to a named variable to get the identifier of
;                     the current window.
;
; PACKAGE:
;
;    Interactive Graphics Library (IGL)
;
; AUTHORS:
;
;        RAPHAEL SADOUN
;        Graduate Student
;        Institut d'Astrophysique de Paris
;        98 bis boulevard Arago
;        75014 PARIS FRANCE
;        E-mail: raphael.sadoun@gmail.com
;
;
; MODIFICATION HISTORY:
;
;     Written by: Raphael Sadoun, 24 April 2012
;-
;*****************************************************************************************************
FUNCTION IGL_GetCurrentWindow, currentID=currentID

  COMPILE_OPT idl2, HIDDEN  
  ON_ERROR, 2

  retVal = obj_new()

  currentID = IGL_GetSysVars('currentWindow')
  IF ((currentID GE 0) AND (currentID LT 50)) THEN BEGIN
     windowObjRefs = IGL_GetSysVars('WindowObjRefs')
     retVal = windowObjRefs[currentID]
  ENDIF

  return, retVal
  
END
